package utils;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Sets;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

public class TestJson {

    public static void json() {
        String json2 = "{\n" +
                "        \"DISCNT_NAME\": \"139邮箱(免费版)\",\n" +
                "        \"DISCNT_CODE\": \"1726\",\n" +
                "        \"SPEC_TAG\": \"0\",\n" +
                "        \"END_DATE\": \"2021-02-28 23:59:59.0\",\n" +
                "        \"START_DATE\": \"2014-05-21 16:38:00.0\",\n" +
                "        \"SPECTAG\": \"正常产品优惠\",\n" +
                "        \"PRODUCT_ID\": \"50000000\",\n" +
                "        \"RELATION_TYPE_CODE\": null,\n" +
                "        \"PRODUCT_NAME\": \"平台服务附加产品\"\n" +
                "    }";

        JSONObject jsonObject2 = JSONObject.parseObject(json2);

        Set temp = new HashSet();
        jsonObject2.keySet().forEach(key -> {
            if(null != jsonObject2.getString(key)) {
                temp.add(key);
                System.out.println(key);
            }
        });
        System.out.println("------------------");
        jsonObject2.keySet().forEach(key -> {
            if(null != jsonObject2.getString(key)) {
                temp.add(key);
                System.out.println(jsonObject2.getString(key));
            }
        });
        System.out.println("------------------");
        System.out.println(temp.size());
    }

    public static void param() {
        String str = "SERIAL_NUMBER: 13802111822\n" +
                "USER_ID: 15951205088674\n" +
                "EPARCHY_CODE: 0022\n" +
                "FUNCTION_TYPE: 1";
        String[] strs = str.split("\n");
        int i = 0;
        for (String s : strs) {
            System.out.println(s.split(":")[0]);
            i++;
        }
        System.out.println("------------------");
        for (String s : strs) {
            System.out.println(s.split(":")[1]);
        }
        System.out.println("------------------");
        System.out.println(i);
    }


    public static void result() {
        String str = "1 NATIONALITY_CODE String 1 国籍码  \n" +
                "2 LOCAL_NATIVE_CODE String 1 籍贯码  \n" +
                "3 FOLK_CODE String 1 民族码  \n" +
                "4 LANGUAGE_CODE String 1 语言码  \n" +
                "5 RELIGION_CODE String 1 信仰  \n" +
                "6 CHARACTER_TYPE_CODE String 1 性格类型  \n" +
                "7 MARRIAGE String 1 婚姻状况  \n" +
                "8 EDUCATE_DEGREE_CODE String 1 教育程度  \n" +
                "9 REVENUE_LEVEL_CODE String 1 收入等级  \n" +
                "10 WORK_DEPART String 1 工作部门  \n" +
                "11 COMMUNITY_ID String 1 社会保障号  \n" +
                "12 WEBUSER_ID String 1 网站注册名";
        String[] strs = str.split("\n");
        int i = 0;
        for (String s : strs) {
            System.out.println(s.split(" ")[1]);
            i++;
        }
        System.out.println("------------------");
        for (String s : strs) {
            System.out.println(s.split(" ")[4]);
        }
        System.out.println("------------------");
        System.out.println(i);
    }


    public static void interfaceCompare() {
        String lpx = "SS.GetUser360ViewSVC.isExistManyUserInfo\n" +
                "SS.GetUser360ViewSVC.qryUserInfo\n" +
                "SS.GetUser360ViewSVC.qrySPInfo\n" +
                "SS.GetUser360ViewSVC.getUserAcctDayInfo\n" +
                "SS.GetUser360ViewSVC.qryCreditValue\n" +
                "SS.GetUser360ViewSVC.qryUserScoreInfo\n" +
                "SS.GetUser360ViewSVC.qryPostInfo\n" +
                "SS.GetUser360ViewSVC.qryCustInfo\n" +
                "SS.GetUser360ViewSVC.qryGroupInfo\n" +
                "SS.GetUser360ViewSVC.qryVpmnGroupInfo\n" +
                "SS.GetUser360ViewSVC.checkPsptInfo\n" +
                "SS.GetUser360ViewSVC.qryOperatorInfo\n" +
                "SS.GetUser360ViewSVC.qryUsePersonDataInfo\n" +
                "SS.GetUser360ViewSVC.qryUserSvcInfo\n" +
                "SS.GetUser360ViewSVC.qryUserDiscntInfos\n" +
                "SS.GetUser360ViewSVC.qryAccountInfo\n" +
                "SS.GetUser360ViewSVC.getPrePayInfo\n" +
                "SS.GetUser360ViewSVC.queryUserScoreInfo\n" +
                "SS.GetUser360ViewSVC.queryUserValideInfo\n" +
                "SS.GetUser360ViewSVC.queryUserRedInfo\n" +
                "SS.GetUser360ViewSVC.getMoneyLimit\n" +
                "SS.GetUser360ViewSVC.qryProductInfo\n" +
                "SS.GetUser360ViewSVC.qryFlatInfo\n" +
                "SS.GetUser360ViewSVC.qryDsmpFlat\n" +
                "SS.GetUser360ViewSVC.qrySwitchs\n" +
                "SS.GetUser360ViewSVC.qryConsumptionInfo\n" +
                "SS.GetUser360ViewSVC.qryPackage\n" +
                "SS.GetUser360ViewSVC.queryGPRSUseTotal\n" +
                "SS.GetUser360ViewSVC.qryTradeHistoryInfo\n" +
                "SS.GetUser360ViewSVC.IsHasWidenet\n" +
                "SS.GetUser360THViewSVC.qryThBaseInfo\n" +
                "SS.GetUser360THViewSVC.qryThAcceptInfo\n" +
                "SS.GetUser360THViewSVC.qryThPlatSvcInfo\n" +
                "SS.GetUser360THViewSVC.qryThScoreInfo\n" +
                "SS.GetUser360THViewSVC.qryThProductInfo\n" +
                "SS.GetUser360THViewSVC.qryThDiscntInfo\n" +
                "SS.GetUser360THViewSVC.qryThCustomInfo\n" +
                "SS.GetUser360THViewSVC.qryChannleIdiInfo\n" +
                "SS.GetUser360THViewSVC.qryQRCodeInfo\n" +
                "SS.GetUser360THViewSVC.qryQRCodeOtherInfo\n" +
                "SS.GetUser360THViewSVC.qryThSvcInfo\n" +
                "SS.GetUser360THViewSVC.qryThSvcStatusInfo\n" +
                "SS.GetUser360THViewSVC.qryThResInfo\n" +
                "SS.GetUser360THViewSVC.qryThRelationInfo\n" +
                "SS.GetUser360THViewSVC.qryThContactInfo\n" +
                "SS.GetUser360THViewSVC.qryThAssureInfo\n" +
                "SS.GetUser360THViewSVC.qryThCardInfo\n" +
                "SS.GetUser360THViewSVC.qryThOtherInfo\n" +
                "SS.GetUser360THViewSVC.qryThRemarkInfo\n" +
                "SS.GetUser360ViewSVC.qryRelationInfo\n" +
                "SS.GetUser360ViewSVC.qryForegiftInfo\n" +
                "SS.GetUser360ViewSVC.getUserAttrInfo\n" +
                "SS.GetUser360ViewSVC.qryTree\n" +
                "SS.GetUser360ViewSVC.queryInfo\n" +
                "SS.GetUser360ViewSVC.queryWidenetInfo\n" +
                "SS.GetUser360ViewSVC.widenetInfoShow\n" +
                "SS.GetUser360ViewSVC.qryUserMemberInfo\n" +
                "SS.GetUser360ViewSVC.qryUserMemberRightsInfo";

        String yang = "SS.GetUser360HisSVC.qryUserInfoBySN\n" +
                "SS.CustomerHisInfoSVC.qryHisUserInfo\n" +
                "SS.GetUser360ViewSVC.qrySPInfo\n" +
                "SS.GetUser360ViewSVC.getUserAcctDayInfo\n" +
                "SS.GetUser360ViewSVC.qryCreditValue\n" +
                "SS.GetUser360ViewSVC.qryCreditState\n" +
                "SS.CustomerHisInfoSVC.getAllUserRes\n" +
                "SS.CustomerHisInfoSVC.qryPostInfo\n" +
                "SS.GetUser360ViewSVC.qryCustInfo\n" +
                "SS.GetUser360ViewSVC.qryGroupInfo\n" +
                "SS.GetUser360ViewSVC.qryVpmnGroupInfo\n" +
                "SS.GetUser360ViewSVC.checkPsptInfo\n" +
                "SS.GetUser360ViewSVC.qryOperatorInfo\n" +
                "SS.GetUser360ViewSVC.qryPsptCheckInfo\n" +
                "SS.CustomerHisInfoSVC.getAllUserSvc\n" +
                "SS.GetUser360ViewSVC.getUserCustAccInfo\n" +
                "SS.CustomerHisInfoSVC.getAllUserDiscnt\n" +
                "SS.GetUser360ViewSVC.getUserCustAccInfo\n" +
                "SS.CustomerHisInfoSVC.qryAccountInfo\n" +
                "SS.CustomerHisInfoSVC.qryHisUserInfo\n" +
                "SS.GetUser360ViewSVC.queryUserScoreInfo\n" +
                "SS.GetUser360ViewSVC.queryUserValideInfo\n" +
                "SS.GetUser360ViewSVC.queryUserRedInfo\n" +
                "SS.GetUser360ViewSVC.getMoneyLimit\n" +
                "SS.CustomerHisInfoSVC.getAllUserProduct\n" +
                "SS.GetUser360HisSVC.qryTradeHistoryInfo\n" +
                "SS.GetUser360ViewSVC.initTradeHistoryInfo\n" +
                "SS.GetUser360ViewSVC.qryTradeTypeCode\n" +
                "SS.CustomerHisInfoSVC.getAllUserRelation\n" +
                "SS.GetUser360ViewSVC.getUserCustAccInfo\n" +
                "SS.GetUser360ViewSVC.qryForegiftInfo\n" +
                "SS.CustomerHisInfoSVC.getAllUserPlatSvc\n" +
                "SS.CustomerHisInfoSVC.qryDsmpPlat\n" +
                "SS.CustomerHisInfoSVC.qrySwitchs\n" +
                "SS.CustomerHisInfoSVC.getAllUserAttr\n" +
                "SS.CustomerHisInfoSVC.queryInfo\n" +
                "SS.CustomerHisInfoSVC.qryTree\n" +
                "SS.GetUser360THViewSVC.qryThBaseInfo\n" +
                "SS.GetUser360THViewSVC.qryThAcceptInfo\n" +
                "SS.GetUser360THViewSVC.qryThPlatSvcInfo\n" +
                "SS.GetUser360THViewSVC.qryThScoreInfo\n" +
                "SS.GetUser360THViewSVC.qryThProductInfo\n" +
                "SS.GetUser360THViewSVC.qryThSvcInfo\n" +
                "SS.GetUser360THViewSVC.qryThSvcStatusInfo\n" +
                "SS.GetUser360THViewSVC.qryThResInfo\n" +
                "SS.GetUser360THViewSVC.qryThRelationInfo\n" +
                "SS.GetUser360THViewSVC.qryThDiscntInfo\n" +
                "SS.GetUser360THViewSVC.qryThContactInfo\n" +
                "SS.GetUser360THViewSVC.qryThAssureInfo\n" +
                "SS.GetUser360THViewSVC.qryThCardInfo\n" +
                "SS.GetUser360THViewSVC.qryThOtherInfo\n" +
                "SS.GetUser360THViewSVC.qryThRemarkInfo";
        String[] split = lpx.split("\n");
        String[] splitYang = yang.split("\n");

        HashSet<String> liSet = Sets.newHashSet(split);
        HashSet<String> yangSet = Sets.newHashSet(splitYang);
        System.out.println("li Size:" + liSet.size());
        System.out.println("yang Size:" + yangSet.size());
        Set liCopy = (Set)liSet.clone();
        Set yangCopy = (Set)yangSet.clone();
        liCopy.removeAll(yangSet);
        System.out.println("li单独存在接口：" + liCopy.size() + "::::" + liCopy);
        yangCopy.removeAll(liSet);
        System.out.println("yang单独存在接口：" + yangCopy.size() + "::::" + yangCopy);
        liSet.removeAll(liCopy);
        System.out.println("重复接口：" + liSet.size() + "::::" + liSet);
        System.out.println("----------------------");
        yangCopy.forEach(str1 -> {
            System.out.println(str1);
        });
//        AtomicInteger atomicInteger = new AtomicInteger(10);
//        AtomicLong atomicLong = new AtomicLong(10);
//        CountDownLatch countDownLatch = new CountDownLatch(10);
//        countDownLatch.countDown();
//        countDownLatch.await();
    }



    public static void main(String[] args) {
//        json();
//        param();
//        result();
        interfaceCompare();
    }
}
